package com.wbcs.system.buttons;

import com.wbcs.config.component.IComponentConfigBean;
import com.wbcs.config.component.application.report.ReportBean;
import com.wbcs.system.ReportRequest;
import com.wbcs.util.Consts_Private;

public class SearchButton extends WbcsButton
{
    public SearchButton(IComponentConfigBean ccbean)
    {
        super(ccbean);
    }

    @Override
	public String getButtonType()
    {
        return Consts_Private.SEARCH_BUTTON;
    }

    @Override
	public String showButton(ReportRequest rrequest,String dynclickevent)
    {
        if(!(((ReportBean)ccbean).getSbean().isExistConditionWithInputbox(rrequest)))
        {
            return "";
        }
        if(dynclickevent==null||dynclickevent.trim().equals(""))
        {
            dynclickevent=getSearchEvent(rrequest);
        }
        return super.showButton(rrequest,dynclickevent);
    }
    
    @Override
	public String showButton(ReportRequest rrequest,String dynclickevent,String button)
    {
        if(!(((ReportBean)ccbean).getSbean().isExistConditionWithInputbox(rrequest)))
        {
            return "";
        }
        if(dynclickevent==null||dynclickevent.trim().equals(""))
        {
            dynclickevent=getSearchEvent(rrequest);
        }
        return super.showButton(rrequest,dynclickevent,button);
    }
    
    private String getSearchEvent(ReportRequest rrequest)
    {
        return "searchReportData('"+ccbean.getPageBean().getId()+"','"+ccbean.getId()+"')";
    }
}
